package homework03;

public class homework04 {
	public static void main(String[] args) {
		System.out.println(Meth("dajlskldjsalkdjsalkda","djaskldjlsak"));
	}
	public static String Meth(String str1,String str2){
		String maxStr = (str1.length() >= str2.length())? str1 : str2;
        String minStr = (str1.length() <  str2.length())? str1 : str2;
        int length = minStr.length();

        for (int i = 0; i < length; i++){
            for (int x = 0, y = length - i; y <= length; x++, y++){
                String subStr = minStr.substring(x, y);
                if (maxStr.contains(subStr)){
                    return subStr;
                }
            }
        }

        return null;
	}
}
